layui.use(['form', 'element', 'layer', 'jquery', 'laypage'], function () {
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        laypage = layui.laypage,
        element = layui.element;
    $ = layui.jquery;

    $("#Contact_business").click(function () {
        if (user_islogin !== "True") {
            top.layer.msg("您还没有登录，请先登录！");
            // top.location.herf='/Login/UserLogin/';
            return false;
        }
        var goodsid = Number($('#goodslistsid').text());
        var goodsuploadid = Number($('#goodslistsuploadid').text());
        console.log(goodsid, goodsuploadid)
        layer.prompt({title: '填写您的手机号，稍后商家会联系您！'}, function (text, index) {
            $.post("/business/Contact/Add/", {
                goods: goodsid,
                businessuser: goodsuploadid,
                cphone: text
            }, function (res) {
                if (res.isSuccess) {
                    top.layer.msg("发送成功！");
                    // tableIns.reload();
                } else {
                    top.layer.msg(res.msg);
                    return false;
                }
            });
            layer.close(index);
        });
    });

    form.on("submit(comment)", function (data) {
        if (user_islogin !== "True") {
            top.layer.msg("您还没有登录，请先登录！");
            // top.location.herf='/Login/UserLogin/';
            return false;
        }
        var goodsid = Number($('#goodslistsid').text());
        // var goodsuploadid = Number($('#goodslistsuploadid').text());
        var txtcomment = $("#txtcomment").val();
        if (txtcomment === '') {
            top.layer.msg("请输入评论内容！");
            return false;
        }
        console.log(txtcomment, goodsid)
        var index = layer.msg('评论中，请稍候...', {icon: 16, time: false, shade: 0.8});
        $.post("/business/Comments/Add/", {
            goods: goodsid,  //id
            body: txtcomment
        }, function (res) {
            top.layer.close(index);
            if (res.isSuccess) {
                top.layer.msg("评论成功！");
                //刷新页面
                console.log(location.href);
                window.location.href = location.href;
            } else {
                top.layer.msg(res.msg);
                return false;
            }
        });
        return false;
    })

});